/******************************************************************************
 * 與笈成主程式 jicheng.js 相關的樣式表
 *
 * - 包含一些特殊元素的定義
 * - 頁面主內容放 main，可用 .main 替代須以同樣格式排版的元素（如檢索結果）
 * - 直書模式：html 加上 .直書
 * - 各種資料頁面類型：在 .main 加上 [data-render="<頁面類型>"]
 *****************************************************************************/

/**
 * 工具欄
 */
#page-panel-open-wrapper {
  position: fixed;
  top: 1em;
  right: 1em;
  outline: 10px solid rgba(233, 233, 233, 0.8);
  background-color: rgba(233, 233, 233, 0.8);
  width: 2em;
  height: 2em;
  writing-mode: horizontal-tb;
}

#page-panel-open {
  display: block;
  margin: .125em 0 .1875em;
  border-top: .9375em double #aaa;
  border-bottom: .3125em solid #aaa;
  height: .3125em;
}

#page-panel {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  background-color: rgba(0, 0, 0, 0.4);
  background-clip: padding-box;
  padding: 1.5em;
  font-size: 16px;
  line-height: 1.5;
  writing-mode: horizontal-tb;
}

#page-panel-close {
  position: absolute;
  z-index: 15;
  display: block;
  top: 4px;
  right: 4px;
  padding: 6px;
  width: 16px;
  height: 16px;
  font-size: 16px;
  line-height: 16px;
  font-weight: bolder;
  color: #FFF;
  text-shadow: 1px 1px 2px black;
  text-decoration: none;
}

#page-panel-close:hover {
  background-color: #04b;
}

#page-panel > div {
  position: relative;
  margin: auto;
  width: 100%;
  height: 100%;
  max-width: 800px;
  background-color: #DDD;
  box-shadow: 0.25em 0.25em 0.5em black;
}

#page-panel [role="tablist"] {
  margin: 0;
  padding: 4px;
  height: 32px;
  background-color: #BBB;
  white-space: nowrap;
  overflow-x: auto;
}

#page-panel [role="tablist"] li {
  display: inline-block;
  list-style: none;
}

#page-panel [role="tab"] {
  display: block;
  background-color: inherit;
  border: none;
  outline: none;
  cursor: pointer;
  height: 32px;
  padding: 6px 8px;
  font-size: 16px;
  line-height: 16px;
  font-weight: bolder;
}

#page-panel [role="tab"]:hover {
  background-color: #DDD;
}

#page-panel [role="tab"]:focus {
  outline: 2px solid #3399FF;
}

#page-panel [role="tab"][aria-selected="true"] {
  background-color: #CCC;
}

#page-panel-tabpanels {
  position: absolute;
  overflow: auto;
  top: 40px;
  bottom: 0;
  left: 0;
  right: 0;
}

#page-panel [role="tabpanel"] {
  margin: auto;
  padding: 10px 1em;
  max-width: 800px;
}

#page-panel [role="tabpanel"] details {
  margin-bottom: 0.5em;
}

#page-panel [role="tabpanel"] details summary {
  padding: 0.125em;
  background-color: #CCCCEE;
  margin-bottom: 0.25em;
}

#page-panel [role="tabpanel"] label {
  white-space: nowrap;
}

#page-panel-tabpanel-search {
  font-size: initial;
  line-height: initial;
}

#page-panel-tabpanel-search > div {
  width: 100%;
}

#page-panel-tabpanel-toc {
  font-size: 1rem;
}

#page-panel-tabpanel-toc ol {
  margin: 0;
  padding: 0;
  counter-reset: 控制台目錄;
}

#page-panel-tabpanel-toc ol li {
  list-style: none;
  margin: 0;
  padding: 0;
}

#page-panel-tabpanel-toc ol li::before {
  counter-increment: 控制台目錄;
  content: counters(控制台目錄, ".") ". ";
}

#page-panel-tabpanel-toc a.current {
  color: black;
  font-weight: bold;
}

/**
 * 直書呈現模式
 */
html.直書 {
  writing-mode: vertical-rl;
}

html.直書 #page-header > h1 {
  margin: 2em 0;
}

html.直書 .main > header > h1 {
  margin: 0 1rem;
  border-bottom: none;
  border-left: double #a2a9b1;
}

html.直書 .main > footer {
  margin-top: 0;
  margin-right: 2rem;
}

html.直書 .main h1,
html.直書 .main h2 {
  border-bottom: none;
  border-left: 1px solid #a2a9b1;
}

html.直書 .main h1,
html.直書 .main h2,
html.直書 .main h3,
html.直書 .main h4,
html.直書 .main h5,
html.直書 .main h6 {
  margin: 0 2rem 0 1rem;
}

.直立 {
  text-orientation: upright;
}

.橫向 {
  text-combine-upright: all;
}

/**
 * 數種實用方盒
 *
 * ref: https://www.w3.org
 */

div.issue,
div.example,
div.note,
div.advisement {
  margin: 1em auto;
  padding: .5em;
  border: .5em;
  border-left-style: solid;
  break-inside: avoid;
  page-break-inside: avoid;
  overflow: auto;
}

html.直書 div.issue,
html.直書 div.example,
html.直書 div.note,
html.直書 div.advisement {
  margin: auto 1em;
  border-left-style: unset;
  border-top-style: solid;
}

div.issue {
  border-color: #e05252;
  background: #fbe9e9;
}

div.example {
  border-color: #e0cb52;
  background: #fcfaee;
}

div.note {
  border-color: #52e052;
  background: #e9fbe9;
}

div.advisement {
  border-color: orange;
  background: #fec;
}

div.issue pre,
div.example pre,
div.note pre,
div.advisement pre {
  line-height: 1.5;
}

/**
 * table.標準框線
 */
table.標準框線 {
  border-collapse: collapse;
}

table.標準框線 > tbody > tr > td,
table.標準框線 > tbody > tr > th {
  border: 1px solid black;
  padding: 2px;
}

/**
 * ol.階層列表：以階層式編號顯示多層 ol, li
 *
 * - 範例：
 *   <ol class="階層列表">
 *   <li>項目一
 *     <ol>
 *     <li>項目一之一
 *       <ol>
 *       <li>項目一之一之一</li>
 *       </ol>
 *     </li>
 *     <li>項目一之二</li>
 *     </ol>
 *   </li>
 *   <li>項目二</li>
 *   </ol>
 *
 *   輸出：
 *   1. 項目一
 *   1.1. 項目一之一
 *   1.2.1. 項目一之一之一
 *   1.2. 項目一之二
 *   2. 項目二
 *   ...
 */
ol.階層列表, ol.階層列表 ol {
  padding: 0;
  counter-reset: 階層列表;
}

ol.階層列表 li {
  list-style: none;
  margin: 0;
}

ol.階層列表 li::before {
  counter-increment: 階層列表;
  content: counters(階層列表, ".") ". ";
}

/**
 * 表單樣式
 */

button.plain {
  margin: 0;
  outline: none;
  border: 0;
  border-radius: .2em; /* Some browsers like Firefox applies this to outline */
  background: transparent;
  padding: 0;
  height: 1em;
  font-size: 1em;
  line-height: 1em;
}

button.plain:focus {
  outline: 1px dotted black;
  background: white;
}

button.plain:hover {
  outline: 1px solid black;
  background: white;
}

/**
 * 關鍵詞上色
 */
mark.kw1 {
  background-color: #88FEFE;
}

mark.kw2 {
  background-color: #88FF88;
}

mark.kw3 {
  background-color: #FF88FF;
}

mark.kw4 {
  background-color: #FFFF88;
}

mark.kw5 {
  background-color: #CCFEFE;
}

mark.kw6 {
  background-color: #CCFFCC;
}

mark.kw7 {
  background-color: #FFCCFF;
}

/**
 * 列印樣式
 */
@media print {
  #page-panel, #page-panel-open-wrapper {
    display: none;
  }

  dl.元資料 {
    background-color: unset;
    border: 1px solid black;
  }
}
